Skip to content

feat: add missing formatters in config and UT#508

Open
andrestejerina97 wants to merge 2 commits intomainfrom
feature/add-missing-ut-formatters
Open

feat: add missing formatters in config and UT#508
andrestejerina97 wants to merge 2 commits intomainfrom
feature/add-missing-ut-formatters

Conversation

@andrestejerina97
Copy link
Copy Markdown
Contributor

@andrestejerina97 andrestejerina97 commented Feb 24, 2026

ref: https://app.clickup.com/t/86b8nemnj

Summary by CodeRabbit

  • Bug Fixes

    • Fixed RSVP Invitation audit logs to correctly identify participants using the correct source.
  • New Features

    • Expanded audit logging coverage to Companies, Presentation Categories, Presentation Types, and RSVP-related entities including templates and question types.
  • Tests

    • Added comprehensive test coverage for all audit log formatters validating creation, update, and deletion event logging.

@andrestejerina97 andrestejerina97 marked this pull request as ready for review February 24, 2026 23:22
@andrestejerina97 andrestejerina97 force-pushed the feature/add-missing-ut-formatters branch from 953ae62 to 793b827 Compare February 25, 2026 19:31
@andrestejerina97
Copy link
Copy Markdown
Contributor Author

@martinquiroga-exo ready to review

@andrestejerina97
Copy link
Copy Markdown
Contributor Author

@martinquiroga-exo

Copy link
Copy Markdown
Contributor

@martinquiroga-exo martinquiroga-exo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrestejerina97 please see comment

Comment thread tests/OpenTelemetry/Formatters/PresentationTypeAuditLogFormatterTest.php Outdated
Copy link
Copy Markdown
Contributor

@caseylocker caseylocker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blockers

  1. Inheritance gap — RSVPQuestionTemplateAuditLogFormatter is dead code in production. Traced the path: AuditEventListener.php:45-58 hands Doctrine's concrete entity to the strategy, AuditLogOtlpStrategy.php:59 passes it through unchanged, AuditLogFormatterFactory.php:138 does exact get_class($subject) lookup. No parent walk anywhere in app/Audit — grep for getRootEntityName|class_parents|is_subclass_of|getParentClass is empty. And SummitRSVPTemplateQuestionFactory.php:38-80 only ever instantiates concrete subtypes (9 cases, no default) — there's no production path that creates a bare RSVPQuestionTemplate. So every real audit event arrives as RSVPDropDownQuestionTemplate, RSVPCheckBoxListQuestionTemplate, etc.; the parent-class config key at audit_log.php:283-286 never matches. Same shape for PrivatePresentationCategoryGroup per PresentationCategoryGroup.php:31. Fix: register each concrete subclass individually — that's the precedent already in this file (SummitVenue/SummitVenueRoom/SummitExternalLocation/SummitHotel/SummitAirport at lines 107,111,135,139,143,147) — or have getFormatterByContext fall back to class_parents() on a miss.

  2. Martin's 'name''type' comment is still sitting there 6 weeks later. tests/OpenTelemetry/Formatters/PresentationTypeAuditLogFormatterTest.php:73 uses change-set key 'name', but the Doctrine property is $type (SummitEventType.php:37-38, #[ORM\Column(name: 'Type')]). Passes only because buildChangeDetails doesn't validate keys. One line.

  3. 52 commits behind main, GitHub flags CONFLICTING. The conflict surface is just the new block at config/audit_log.php:259-289. Rebase.

@andrestejerina97 andrestejerina97 force-pushed the feature/add-missing-ut-formatters branch from 793b827 to c853968 Compare May 8, 2026 00:37
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 8, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR extends audit logging coverage to company, presentation catalog, and RSVP entities by wiring formatters in configuration, fixing RSVP invitation identity retrieval from invitee rather than attendee, and adding eight comprehensive test suites validating formatter behavior for creation, update, and deletion events.

Changes

Audit Logging for Company, Presentation, and RSVP Entities

Layer / File(s) Summary
Configuration and Formatter Wiring
config/audit_log.php
Adds entity-to-formatter mappings for PrivatePresentationCategoryGroup, Company, PresentationCategory, PresentationType, RSVP, RSVPInvitation, and RSVP question template types to their respective audit formatter implementations.
RSVP Invitation Invitee Identity
app/Audit/ConcreteFormatters/RSVPInvitationAuditLogFormatter.php
$attendeeEmail and $attendeeId are now derived from getInvitee() instead of getAttendee() with preserved null-coalescing fallbacks.
Company Formatter Tests
tests/OpenTelemetry/Formatters/CompanyAuditLogFormatterTest.php
Test suite validates CompanyAuditLogFormatter audit message generation for creation, update, deletion events and null handling for invalid subjects.
Presentation Category Formatter Tests
tests/OpenTelemetry/Formatters/PresentationCategoryAuditLogFormatterTest.php
Test suite verifies PresentationCategoryAuditLogFormatter formats audit messages with event-specific keywords and subject fields (title, code).
Presentation Category Group Formatter Tests
tests/OpenTelemetry/Formatters/PresentationCategoryGroupAuditLogFormatterTest.php
Test suite validates PresentationCategoryGroupAuditLogFormatter audit message content for creation, update, deletion events with mocked subject data.
Presentation Type Formatter Tests
tests/OpenTelemetry/Formatters/PresentationTypeAuditLogFormatterTest.php
Test suite verifies PresentationTypeAuditLogFormatter generates audit messages containing event keywords and subject name.
RSVP and RSVP Invitation Formatter Tests
tests/OpenTelemetry/Formatters/RSVPAuditLogFormatterTest.php, tests/OpenTelemetry/Formatters/RSVPInvitationAuditLogFormatterTest.php
Test suites validate RSVPAuditLogFormatter and RSVPInvitationAuditLogFormatter audit messages with mocked event, member, and invitation entities for all event types.
RSVP Question Template Formatter Tests
tests/OpenTelemetry/Formatters/RSVPQuestionTemplateAuditLogFormatterTest.php
Test suite verifies RSVPQuestionTemplateAuditLogFormatter formats audit messages containing label, requirement flags, and event-specific keywords.
RSVP Template Formatter Tests
tests/OpenTelemetry/Formatters/RSVPTemplateAuditLogFormatterTest.php
Test suite validates RSVPTemplateAuditLogFormatter generates audit messages for creation, update, deletion events with subject title and change tracking.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • smarcet
  • romanetar
  • martinquiroga-exo

Poem

🐰 Hop, hop, the audit logs now sing,
For companies, presentations, and RSVP wings,
Invitees tracked from invitee's view,
Tests confirm each formatter rings true!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add missing formatters in config and UT' directly and accurately summarizes the main change in the pull request, which adds missing audit log formatters to the configuration and includes corresponding unit tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/add-missing-ut-formatters

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 8, 2026

📘 OpenAPI / Swagger preview

➡️ https://OpenStackweb.github.io/summit-api/openapi/pr-508/

This page is automatically updated on each push to this PR.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
tests/OpenTelemetry/Formatters/RSVPTemplateAuditLogFormatterTest.php (1)

82-104: ⚡ Quick win

Strengthen update/deletion assertions to validate payload details.

Current checks ('updated' / 'deleted') are a bit loose. Please assert stable identifiers/details (e.g., template ID/title and changed field values) so formatter regressions don’t slip through.

Suggested assertion hardening
 public function testSubjectUpdateAuditMessage(): void
 {
@@
     $this->assertNotNull($result);
     $this->assertStringContainsString('updated', $result);
+    $this->assertStringContainsString('Gala Dinner RSVP', $result);
+    $this->assertStringContainsString('title', $result);
+    $this->assertStringContainsString('Cocktail Dinner RSVP', $result);
 }
@@
 public function testSubjectDeletionAuditMessage(): void
 {
@@
     $this->assertNotNull($result);
     $this->assertStringContainsString('deleted', $result);
+    $this->assertStringContainsString('Gala Dinner RSVP', $result);
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/OpenTelemetry/Formatters/RSVPTemplateAuditLogFormatterTest.php` around
lines 82 - 104, The tests testSubjectUpdateAuditMessage and
testSubjectDeletionAuditMessage assert only the presence of 'updated'/'deleted'
which is too weak; update them to assert specific payload details produced by
RSVPTemplateAuditLogFormatter: for testSubjectUpdateAuditMessage verify the
formatted message includes the template identifier/title from $this->mockSubject
and the change details from $changeSet (e.g., old and new 'title' values), and
for testSubjectDeletionAuditMessage assert the message contains the template
identifier/title from $this->mockSubject and a clear 'deleted' phrase; use
RSVPTemplateAuditLogFormatter::format, the same
AuditContextBuilder::default()->build() context, and existing
$this->mockSubject/changeSet variables to locate the assertions to strengthen.
config/audit_log.php (1)

323-382: ⚡ Quick win

Add a focused config-wiring test for these new entity mappings.

These entries are runtime bindings, so typos or future class renames can silently disable formatter resolution even when formatter unit tests pass. A small parameterized test asserting entity => strategy pairs would harden this.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/audit_log.php` around lines 323 - 382, Add a parameterized
config-wiring test that verifies each runtime mapping in the audit config
resolves to an existing, instantiable formatter to prevent silent breakage;
create a test (e.g., AuditConfigWiringTest) that loads the audit mapping (keys
like \models\main\Company::class,
\App\Models\Foundation\Summit\Events\RSVP\RSVPTemplate::class and strategy
classes like
\App\Audit\ConcreteFormatters\RSVPQuestionTemplateAuditLogFormatter::class),
iterate expected entity=>strategy pairs, assert the mapping exists in the loaded
config, assert class_exists(strategy) and that the IoC container (or new
strategy via app()->make or new) can instantiate it without error, and
parametrize the test so each pair is a separate assertion case.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/OpenTelemetry/Formatters/CompanyAuditLogFormatterTest.php`:
- Around line 91-95: The test testFormatterReturnsNullForInvalidSubject should
set the formatter's context before calling format so the assertion isolates
invalid-subject behavior; update the test to configure the
CompanyAuditLogFormatter instance (constructed with
IAuditStrategy::EVENT_ENTITY_CREATION) with the same context used in other tests
(e.g. call the formatter's context-setting method used elsewhere in the suite)
and then call $formatter->format(new \stdClass(), []) and assertNull the result.

---

Nitpick comments:
In `@config/audit_log.php`:
- Around line 323-382: Add a parameterized config-wiring test that verifies each
runtime mapping in the audit config resolves to an existing, instantiable
formatter to prevent silent breakage; create a test (e.g.,
AuditConfigWiringTest) that loads the audit mapping (keys like
\models\main\Company::class,
\App\Models\Foundation\Summit\Events\RSVP\RSVPTemplate::class and strategy
classes like
\App\Audit\ConcreteFormatters\RSVPQuestionTemplateAuditLogFormatter::class),
iterate expected entity=>strategy pairs, assert the mapping exists in the loaded
config, assert class_exists(strategy) and that the IoC container (or new
strategy via app()->make or new) can instantiate it without error, and
parametrize the test so each pair is a separate assertion case.

In `@tests/OpenTelemetry/Formatters/RSVPTemplateAuditLogFormatterTest.php`:
- Around line 82-104: The tests testSubjectUpdateAuditMessage and
testSubjectDeletionAuditMessage assert only the presence of 'updated'/'deleted'
which is too weak; update them to assert specific payload details produced by
RSVPTemplateAuditLogFormatter: for testSubjectUpdateAuditMessage verify the
formatted message includes the template identifier/title from $this->mockSubject
and the change details from $changeSet (e.g., old and new 'title' values), and
for testSubjectDeletionAuditMessage assert the message contains the template
identifier/title from $this->mockSubject and a clear 'deleted' phrase; use
RSVPTemplateAuditLogFormatter::format, the same
AuditContextBuilder::default()->build() context, and existing
$this->mockSubject/changeSet variables to locate the assertions to strengthen.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b4288b86-83d2-4ceb-91cc-f251420c60e9

📥 Commits

Reviewing files that changed from the base of the PR and between 34e47f9 and c853968.

📒 Files selected for processing (10)
  • app/Audit/ConcreteFormatters/RSVPInvitationAuditLogFormatter.php
  • config/audit_log.php
  • tests/OpenTelemetry/Formatters/CompanyAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/PresentationCategoryAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/PresentationCategoryGroupAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/PresentationTypeAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/RSVPAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/RSVPInvitationAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/RSVPQuestionTemplateAuditLogFormatterTest.php
  • tests/OpenTelemetry/Formatters/RSVPTemplateAuditLogFormatterTest.php

Comment on lines +91 to +95
public function testFormatterReturnsNullForInvalidSubject(): void
{
$formatter = new CompanyAuditLogFormatter(IAuditStrategy::EVENT_ENTITY_CREATION);
$result = $formatter->format(new \stdClass(), []);
$this->assertNull($result);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Set formatter context in invalid-subject test to isolate the assertion.

This test currently verifies null without the same context setup used elsewhere, so a future context-related failure could mask the real intent (invalid subject handling).

Proposed patch
 public function testFormatterReturnsNullForInvalidSubject(): void
 {
     $formatter = new CompanyAuditLogFormatter(IAuditStrategy::EVENT_ENTITY_CREATION);
+    $formatter->setContext(AuditContextBuilder::default()->build());
     $result = $formatter->format(new \stdClass(), []);
     $this->assertNull($result);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public function testFormatterReturnsNullForInvalidSubject(): void
{
$formatter = new CompanyAuditLogFormatter(IAuditStrategy::EVENT_ENTITY_CREATION);
$result = $formatter->format(new \stdClass(), []);
$this->assertNull($result);
public function testFormatterReturnsNullForInvalidSubject(): void
{
$formatter = new CompanyAuditLogFormatter(IAuditStrategy::EVENT_ENTITY_CREATION);
$formatter->setContext(AuditContextBuilder::default()->build());
$result = $formatter->format(new \stdClass(), []);
$this->assertNull($result);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/OpenTelemetry/Formatters/CompanyAuditLogFormatterTest.php` around lines
91 - 95, The test testFormatterReturnsNullForInvalidSubject should set the
formatter's context before calling format so the assertion isolates
invalid-subject behavior; update the test to configure the
CompanyAuditLogFormatter instance (constructed with
IAuditStrategy::EVENT_ENTITY_CREATION) with the same context used in other tests
(e.g. call the formatter's context-setting method used elsewhere in the suite)
and then call $formatter->format(new \stdClass(), []) and assertNull the result.

@andrestejerina97
Copy link
Copy Markdown
Contributor Author

it's ready to review @caseylocker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants